package com.ltxtiyu.video.api;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ltxtiyu.video.common.DataGridParam;
import com.ltxtiyu.video.common.SecurityConstant;
import com.ltxtiyu.video.entity.TokenStore;
import com.ltxtiyu.video.entity.User;
import com.ltxtiyu.video.service.app.TokenStoreService;
import com.ltxtiyu.video.service.app.TopicService;
import com.ltxtiyu.video.service.app.UserService;
import com.ltxtiyu.video.tool.ParamTool;
import com.ltxtiyu.video.tool.Tool;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/apiTopic")
public class ApiTopic {
    @Reference
    TopicService topicService;

    @RequestMapping("/topicIndex")
    public String topicIndex(HttpServletRequest request){
        Map<String, String> params = ParamTool.requestToParamMap(request);
        DataGridParam dgp = Tool.genDataGridParam(request);
        Integer start = (dgp.getPage() - 1) * dgp.getRows();
        Integer rows = dgp.getRows();
        params.put("start", String.valueOf(start));
        params.put("rows", String.valueOf(rows));
        params.put("userId",String.valueOf(-1)); // 默认用户没有登陆是-1
        return topicService.topicIndex(params);
    }
}
